package ru.ifmo.trafficspy.tests;


import static org.junit.Assert.assertTrue;

import java.util.ArrayList;

import org.junit.Before;
import org.junit.Test;

import ru.ifmo.trafficspy.analyzer.clustering.ClusterizerFactory;
import ru.ifmo.trafficspy.analyzer.clustering.KMeansClusterizer;

public class ClusterizerFactoryTest {

	private KMeansClusterizer kmc;
	
	@Test
	public void test1() {
		kmc = ClusterizerFactory.getKMeansClusterizer(new double[] {0, 2, 3}, 3);
		assertTrue(kmc.getCluster(2) == 1);
		assertTrue(kmc.getCluster(1.5) == 1);
		assertTrue(kmc.getCluster(0.5) == 0);
		assertTrue(kmc.getCluster(3.5) == 2);
		assertTrue(kmc.getCluster(-10) == -1);
	}

	@Test
	public void test2() {
		kmc = ClusterizerFactory.getKMeansClusterizer(new double[] {0, 2, 3}, 2);
		assertTrue(kmc.getCluster(2) == 1);
		assertTrue(kmc.getCluster(1.5) == 1);
		assertTrue(kmc.getCluster(0.5) == 0);
		assertTrue(kmc.getCluster(3.5) == 1);
		assertTrue(kmc.getCluster(-10) == -1);
	}
	
}
